The oAuth2PermissionGrant object keeps a record of user consented permissions (Delegated Permissions) in a tenant. There is one OAuth2PermissionGrant object (identified by Consent ID) for each combination of client application, resource application, and user. The sample PowerShell script in this post will perform the following tasks:
- Remove all MS Graph Delegated permissions (if any) for the user
- Perform user consent for an initial set of MS Graph permission
- Update the consented permission list with some additional permissions
- Remove some permissions from the consented permission list
- Remove (revoke) all consented permissions for the user
Pre-Requisite
This post assumes you already have an app registration created in your tenant and a user you intend to perform consent on.
Note: There might be a short time delay for the permissions to get updated in the portal
[gist id=”9bbae0c0660a83ddf2aadb844b03a454″ file=”OAuth2PermissionGrant.ps1″]
For removing Admin Consented Delegated permission refer to Revoke Admin Consent for a delegated permission on a Service Principal with the MS Graph PowerShell SDK | Azure Active Directory Developer Support Team (aaddevsup.xyz) for more info